#include "Matrix.h"
#include <vector> 
#include <iostream>

using std::cout;
using std::cin;
using std::endl;
using std::vector;

Matrix readMatrix(){
    int rows = 0;
    cout << "Number of rows: ";
    cin >> rows;

    int cols = 0;
    cout << "Number of columns: ";
    cin >> cols;


    Matrix result(rows, cols);
    cout << result << endl;

    cout << "Enter the values: ";
    for( int i = 0; i < rows; i++ ){
        for(int j = 0; j < cols; j++){
            cin >> result(i, j);
        }
    }

    cout << endl;
    return result;
}
void usage(){
        cout << "What operation would you like to perform?" << endl;
        cout << " 0. Quit" << endl;
        cout << " 1. Inverse" << endl;
        cout << " 2. RREF" << endl;
        cout << " 3. Eigen Values" << endl;
        cout << " 4. Eigen Vectors" << endl;
        cout << " 5. Echelon" << endl;
        cout << " 6. L Factorization" << endl;
        cout << " 7. U Factorization" << endl;
        cout << " 8. Q Factorization" << endl;
        cout << " 9. R Factorization" << endl;
        cout << "10. Determinant" << endl;
        cout << "11. Transpose" << endl;
        cout << "12. Trace" << endl;
        cout << "13. Print this help" << endl;
}

int main(){
    usage();

    int choice = -1;
    while( choice != 0 ){
        cout << "> ";
        cin >> choice;

        switch( choice ){
            case 0:
                break;
            case 1:
                cout << readMatrix().inverse();
                break;
            case 2:
                cout << readMatrix().rref();
                break;
            case 3:
                cout << "Not implemented yet." << endl;
                break;
            case 4:
                cout << "Not implemented yet." << endl;
                break;
            case 5:
                cout << readMatrix().echelon();
                break;
            case 6:
                cout << readMatrix().Lfact();
                break;
            case 7:
                cout << readMatrix().Ufact();
                break;
            case 8:
                cout << readMatrix().Qfact();
                break;
            case 9:
                cout << readMatrix().Rfact();
                break;
            case 10:
                cout << readMatrix().determinant() << endl;;
                break;
            case 11:
                cout << readMatrix().transpose() << endl;;
                break;
            case 12:
                cout << readMatrix().trace() << endl;;
                break;
            case 13:
                usage();
                break;

            default:
                cout << choice << " is not a valid choice, please choose again." << endl;
                break;
        }

    }

    return 0;
}
